﻿<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
	  x:Class="MovieRental_Presentation.Customers" 
      d:DesignWidth="1024" d:DesignHeight="600"
      mc:Ignorable="d"
      WindowTitle="Movie Rental"
	  MinWidth="900"
	  MinHeight="500" 
      ShowsNavigationUI="False" Name="customersPage">

    <Grid Background="{StaticResource backgroundBrush}">
    	<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="250"/>
		</Grid.ColumnDefinitions>
		<Border BorderThickness="{StaticResource borderThickness}" Padding="{StaticResource borderPadding}" Margin="8" CornerRadius="{StaticResource borderCornerRadius}" BorderBrush="{StaticResource borderBrush}" Grid.Column="1">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="210"/>
					<RowDefinition Height="*"/>
				</Grid.RowDefinitions>
				<StackPanel Grid.Row="0">
					<Label Content="Menu" HorizontalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
					<Button x:Name="dashboardButton" Content="Dashboard" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="dashboardButton_Click" />
					<Button x:Name="moviesButton" Content="Movies" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="moviesButton_Click"/>
					<Button x:Name="statisticsButton" Content="Statistics" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="statisticsButton_Click"/>
				</StackPanel>
				<Frame Content="Frame" Grid.Row="1" Source="/MovieRental.Presentation;component/Cart.xaml" NavigationUIVisibility="Hidden"/>
			</Grid>
		</Border>
    	<Border BorderBrush="{StaticResource borderBrush}" BorderThickness="{StaticResource borderThickness}" Margin="8" Padding="{StaticResource borderPadding}" CornerRadius="{StaticResource borderCornerRadius}">
    		<Grid>
    			<Grid.RowDefinitions>
    				<RowDefinition Height="Auto"/>
    				<RowDefinition/>
    			</Grid.RowDefinitions>
    			<Label Content="Customers" Margin="0" d:LayoutOverrides="Height" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
    			<Button x:Name="backButton" Content="Back" HorizontalAlignment="Left" Width="60" Margin="8,8,0,0" Grid.RowSpan="2" Height="60" VerticalAlignment="Top" Click="backButton_Click" />
    			<Grid Grid.Row="1">
    				<Grid.RowDefinitions>
    					<RowDefinition Height="Auto"/>
    					<RowDefinition Height="0.7*"/>
						<RowDefinition Height="Auto"/>			
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="*"/>
					</Grid.ColumnDefinitions>
					<StackPanel x:Name="selectedCustomerPanel" Grid.Column="0" Grid.Row="1" Margin="8">
						<Button x:Name="addButton" Content="Add" Height="50" Margin="0,0,0,8" Width="50" Click="addButton_Click"/>
						<Button Content="Delete" Height="50" Margin="0,0,0,8" Width="50" Name="deleteButton" Visibility="{Binding ElementName=customersDataGrid, Path=SelectedIndex, Converter={StaticResource indexVisibilityConverter}}" Click="deleteButton_Click" />
						<Button x:Name="editButton" Content="Edit" Height="50" Margin="0,0,0,8" Width="50" Click="editButton_Click" Visibility="{Binding ElementName=customersDataGrid, Path=SelectedIndex, Converter={StaticResource indexVisibilityConverter}}" />
						<Button Content="Assign" Height="50" Margin="0,0,0,8" Width="50" Name="assignButton" Click="assignButton_Click" Visibility="{Binding SelectedIndex, Converter={StaticResource indexVisibilityConverter}, ElementName=customersDataGrid}" />
					</StackPanel>
					<TextBox x:Name="searchBox" Text="{Binding Path=SearchString, Mode=OneWayToSource}" BorderBrush="{StaticResource borderBrush}" BorderThickness="1" Background="{StaticResource backgroundBrush}" Foreground="{StaticResource inputBoxBrush}" Grid.Row="0" Grid.Column="1" Margin="8" KeyUp="searchBox_KeyUp" />
					<DataGrid x:Name="customersDataGrid" Grid.Column="1" Margin="8" Grid.Row="1" GridLinesVisibility="None" IsSynchronizedWithCurrentItem="False" IsReadOnly="True" SelectionMode="Single" AutoGenerateColumns="False" RowHeight="40" MouseDoubleClick="customersDataGrid_MouseDoubleClick" ItemsSource="{Binding CustomersList}">
						<DataGrid.Columns>
							<DataGridTextColumn Binding="{Binding Entity.FirstName}" Header="First Name" Width="*"/>
							<DataGridTextColumn Binding="{Binding Entity.LastName}" Header="Last Name" Width="*"/>
							<DataGridTextColumn Binding="{Binding Entity.Email}" Header="Email" Width="*"/>
							<DataGridTextColumn Binding="{Binding Entity.PhoneNo}" Header="PhoneNo" Width="*"/>
                            <DataGridTextColumn Binding="{Binding NotReturnedEditions}" Header="Not Returned Editions" Width="*"/>
							
						</DataGrid.Columns>
					</DataGrid>
					<Expander Grid.Row="3" Grid.Column="1" Margin="8">
						<Expander.Header>
							<TextBlock Text="Top-10 Spendthrifts" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource borderBrush}" Margin="0"/>
						</Expander.Header>
						<Grid MinHeight="150">
							<DataGrid ItemsSource="{Binding TopSpendthrifts}" CanUserSortColumns="False" AutoGenerateColumns="False">
								<DataGrid.Columns>
									<DataGridTextColumn Header="Name" Width="*" Binding="{Binding FullName }" />
									<DataGridTextColumn Header="Spent Money" Width="*" Binding="{Binding Path=SpentMoney, StringFormat=\{0:c\}}"/>
								</DataGrid.Columns>
								
							</DataGrid>
						</Grid>
					</Expander>
    			</Grid>
    		</Grid>
    	</Border>
        
    </Grid>
</Page>
